package br.com.foxinline.servico;

import br.com.foxinline.modelo.Imovel;
import br.com.foxinline.modelo.Registro;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author cadomeireles
 */
@Stateless
public class RegistroServico extends ServicoGenerico<Registro> {

    public RegistroServico() {
        super(Registro.class);
    }

    public List<Registro> pesquisar(Imovel imovel) {

        String sql = "select imovel.registros from Imovel imovel where imovel = :imovel";

        Query query = getEntityManager().createQuery(sql);

        if (imovel != null && imovel.getId() != null) {
            query.setParameter("imovel", imovel);
        }

        return query.getResultList();

    }

}
